from rest_framework import serializers

from contract.log_util.log_serializer import LogSerializer
from contract.models import *


class ContractDetailSerializer(LogSerializer):
    class Meta:
        model = ContractDetail
        fields = '__all__'
        depth = 2


class ContractDetailSerializer_(LogSerializer):
    class Meta:
        model = ContractDetail
        fields = '__all__'


class ContractSerializer(LogSerializer):
    class Meta:
        model = Contract
        fields = '__all__'


class ListContractSerializer(LogSerializer):
    class Meta:
        model = Contract
        fields = '__all__'
        depth = 1


class ContractStatisticalSerializer(serializers.Serializer):
    def update(self, instance, validated_data):
        pass

    def create(self, validated_data):
        pass

    # 到货量总计
    sum_arrived_at_now = serializers.DecimalField(decimal_places=2, max_digits=15)
    # 预付款总计
    sum_prepayments = serializers.DecimalField(decimal_places=2, max_digits=15)
    # 结算金额总计
    sum_settlemen_prepayments = serializers.DecimalField(decimal_places=2, max_digits=15)
    # 结算数量总计
    sum_settlemen_amount = serializers.DecimalField(decimal_places=2, max_digits=15)
    # 结算单价


class SupplierSerializer(serializers.ModelSerializer):
    class Meta:
        model = Supplier
        fields = '__all__'


# ---------------------- 销售相关 --------------------------

class SaleSupplierSerializer(serializers.ModelSerializer):
    class Meta:
        model = SaleSupplier
        fields = '__all__'


class SaleContractSerializer(serializers.ModelSerializer):
    class Meta:
        model = SaleContract
        fields = '__all__'


class ListSaleContractSerializer(serializers.ModelSerializer):
    class Meta:
        model = SaleContract
        fields = '__all__'
        depth = 1


class SaleContractDetailSerializer(serializers.ModelSerializer):
    class Meta:
        model = SaleContractDetail
        fields = '__all__'
        depth = 2


class SaleContractDetailSerializer_(serializers.ModelSerializer):
    class Meta:
        model = SaleContractDetail
        fields = '__all__'


